home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 139_01.zip / KED.H < prev    next >
Text File  |  1993-06-03  |  4KB  |  96 lines

  1.  
  2.  
  3. /*
  4. TITLE:        Karel The Robot;
  5. VERSION:    1.0;
  6. DATE:        09/27/1984;
  7. DESCRIPTION:
  8.     "Header for syntax-directed editor, KED.";
  9. KEYWORDS:    Globals, constants;
  10. SYSTEM:        CP/M 2+;
  11. FILENAME:    KED.H;
  12. AUTHORS:    Linda Rising;
  13. COMPILERS:    BDS C;
  14. REFERENCES:
  15.     AUTHOR: Richard E. Pattis;
  16.     TITLE: "KAREL the Robot: A Gentle Introduction
  17.         to the Art of Programming";
  18.     CITATION: "";
  19. ENDREF
  20. */
  21.  
  22.  
  23. /* global constants */
  24.  
  25. #define MAXCOMM   30          /* number of valid edit commands */
  26. #define MAXTEST   19          /* number of booleans for Karel */
  27. #define MAXNAME   12          /* number of reserved commands */
  28. #define NOMATCH   -1          /* search for valid command fails */
  29. #define CONSOLE    1          /* console output */
  30. #define FILE  struct _buf     /* label for file header */
  31. #define TEST       2          /* frequently referenced commands */
  32. #define POSINT     3     
  33. #define NEWINSTR   4
  34. #define BEG       5
  35. #define BEPGM       6
  36. #define BX         7
  37. #define ND         8
  38. #define NDX        9
  39. #define NDC      10
  40. #define IFF      11
  41. #define THEN      12
  42. #define ELS       13
  43. #define DEF       16
  44. #define MENU      18
  45.  
  46. /* global constants included in the standard library
  47.  
  48. BUFSIZ
  49. CPMEOF
  50. EOF
  51. ERROR
  52. FILE
  53. MAXLINE
  54. NULL  
  55.  */
  56.  
  57. /* global variables */
  58.  
  59. char ibuf1[BUFSIZ];           /* input buffer for parse tree */
  60. char ibuf2[BUFSIZ];           /* output buffer for text */
  61. char *comm[MAXCOMM];          /* valid editor commands */
  62. char *test[MAXTEST];          /* booleans for Karel's pgm */
  63. char *iname[MAXNAME];         /* commands for Karel's pgm */
  64. int insert;                   /* boolean for inserting new node */
  65. int ins;              /* final indent level */
  66. struct tnode {                /* node for parse tree */
  67.      int instr;               /* stored instruction */
  68.      int indent;              /* used for pretty printing */
  69.      int del;                 /* can node be deleted */
  70.      int nfollow;             /* valid next follow statements */
  71.      int sfollow;             /* valid component followers */
  72.      int comp;                /* possible compound statement */
  73.      int cons;                /* start or end of construct */
  74.      int lastin;              /* last defined instruction */
  75.      struct tnode *prev;      /* pointer to preceding node */
  76.      struct tnode *prec;      /* pointer to preceding construct */
  77.      struct tnode *next;      /* pointer to next construct */
  78.      struct tnode *sub;       /* pointer to component instruction */
  79. };
  80. struct tnode *root;           /* points to parse tree */
  81. struct tnode *p;              /* next node to be added */
  82. struct tnode *pr;             /* parent of next node */
  83. struct tnode *curr;           /* current line pointer reference */
  84. struct tnode *temp;           /* reference for end construct */ 
  85. struct tnode *endof;          /* last node added to tree */
  86. struct tnode *insertnode;     /* place holder for insert mode */ 
  87. struct tnode *tempend;        /* last node inserted in tree */ 
  88. struct deftable {             /* symbol table for new instructions */
  89.      char defname[MAXLINE];   /* name of new instruction */
  90.      int nextin;              /* order of definition */
  91.      struct tnode *loc[10];   /* pointers to instr in pgm */
  92. } new[10];                    /* symbol table */
  93. int first;                    /* first loc in symbol table */
  94. int last;                     /* next available loc in table */
  95. int reloc[10];                /* old table loc to new table loc */
  96.